<?php
/**
 * 首页控制器
 * @author:zhulin
 * @since:2012 5.4
 */
class IndexController  extends BaseController{
    /**
     * 首页显示
     */
    public function run(){
        
         /**
          * 产品种类的显示
          */
         $arrTypeInfo = array();
         $typeName = Category_Show::getInstance()->getCategory( $Tid = 0 );
         
         $arrTname = array();
         $arrSName = array();
         foreach( $typeName as $key => $value){ 
            
            $arrTypeInfo[] = array(
                 ''.$value['TId'].'' => Category_Show::getInstance()->getCategory( $TId= $value['TId'] ),
                 'TName' => $value[ 'TName']           
            );
         }
         /**
          * 所有产品列表的显示
          */
         $productInfo = product_Info::getInstance()->getProductInfo( );
         
         /**
          * 浏览历史记录
          */
              if(  isset( $_COOKIE['ProductInfo'])){          
                $arrCookie = unserialize( $_COOKIE['ProductInfo'] );
                //浏览历史记录列表
                $productHistory = Product_Info::getinstance()->getProductHistory( $arrCookie);
              }
         /**
          * 产品推送
          * 
          */
           // 登录用户
         if( isset($_SESSION['UId'])){
             $PId = $value = User_like::getInstance()->getPushInfo();
             if( !empty ( $PId)){
                $productPush =  Product_Info::getInstance()->getProductInfoMulti( $PId );   
             }
             else{
                  $productPush = Product_Info::getInstance()->getProductInfoRand( );
             }
            
         }
         // 未登录用户
         else{
             if( isset( $_COOKIE['userLike'])){
              
                 print_r( unserialize( $_COOKIE['userLike'])  );
                $PId = User_like::getInstance()->getCookieInfo( ); 
            
                $productPush = Product_Info::getInstance()->getProductInfoMulti( $PId );
             
             }
             //随机产生产品
             else{
                 $productPush = Product_Info::getInstance()->getProductInfoRand( );
             }  
         }
         
       
         include TPL_DIR . 'index.php';

    }
     /**
     * 用户登录
     * 
     */
    public function login(){
       
        include TPL_DIR . 'login.php';       
    }
    /**
     * 用户注册
     */
    public function register(){
        
        //Helper_Img::getInstance()->getImgCode();
        include TPL_DIR.'register.php';
    }
    /**
     * 高级用户注册
     */
    public function powerRegister(){ 
        include TPL_DIR.'powerRegister.php';
    }
}